Skip to content

fix: omp one-shot (-p) first request claims plugin mode — await identity registration before dispatch - #1237

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-24_omp-oneshot-register-await
Sep 24, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-24_omp-oneshot-register-await

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #1230

What changed

Mirror of #1228 on the before_provider_request path (src/agent/pi.ts, shared by the omp and pi plugin entries): the handler is now async and awaits registerTools before reporting runtime info and returning the stamped payload, instead of firing it off with void … .catch(…).

For omp the plugin-mode claim is the identity registration (POST /__bili/plugin/register with identity: true) that runs inside registerTools, after the manifest fetch. omp's extension runner awaits async handlers and sends the resolved value as the outgoing payload (verified in the installed omp 18.0.3 dist: emitBeforeProviderRequest awaits each handler; its 30s handler-timeout guard is well above the worst-case hold), so the register now provably lands on the proxy before the request leaves. The proxy binds by that id at request time (consumePluginRegisterFor, src/server.ts) — there is no retroactive upgrade, so order is everything for a one-shot.

Behavior change (intended, flagged per policy)

  • omp first model request now holds until registration completes. Old: dispatch was immediate; registration raced it and, whenever it lost (the deterministic omp -p case), the session bound as an anonymous pfa-* in proxy mode forever. New: the first request waits at most ~manifest-fetch timeout (5s) + identity-register timeout (5s); subsequent requests are instant (sid-cached / pending-deduped / 10s-throttled). A permanently failing manifest fetch still degrades to wire mode (graceful, unchanged).
  • Consequence (the fix): bili omp -p '<prompt>' binds its single dispatch into plugin mode — ACP compression contract + /acp binding by session id — instead of silently running proxy mode. TUI behavior is semantically unchanged (it already self-healed on round 2); round 1 simply no longer rides wire mode.
  • omp runtime-info report timing ([native] omp: three-mode alignment (proxy / launcher / native plugin) + runtime-info #957): old — round 1 left before toolsReady flipped, so the first request reported nothing and the report rode round 2+; new — the report fires during round 1's handler await, i.e. alongside the first request. Same dedup semantics (per model switch), one earlier POST in TUI sessions.
  • pi path: no practical change — pi's before_provider_headers hook (already awaiting since fix: pi one-shot (-p) first request claims plugin mode — await tool registration before header stamp #1228) runs first and completes registration, so the request hook's await returns instantly from the sid cache. If a pi build ever emits only before_provider_request, it now gets the same bounded serialization as omp instead of fire-and-forget.

Why not land #1216 instead

#1216 gates both hooks behind a 5s readiness wait, but (a) it predates #1228 — its pi-header gate would rewrite shipped behavior and conflict on rebase, and (b) its gate releases when toolsReady flips, which happens inside registerTools before postIdentityRegister — so for omp the gate does not serialize behind the identity register and does not fully close this race. Recommend closing #1216 as superseded (owner call).

Verification

  • New regression test #1230: before_provider_request awaits identity registration — omp one-shot (-p) first dispatch claims plugin mode: drives the hook once with no session_start prewarm and asserts the identity register has landed at handler-resolution time (no polling) plus payload stamping and no duplicate register on a second fire. Proven red on pre-fix code (fails with the fix stashed), green with it.
  • Injection-matrix and pi-stamp tests updated to await the now-async hook (assertions unchanged; fakeCtx(undefined) keeps registration a no-op so they stay pure).
  • #957 runtime-info test expectation updated to the new round-1 reporting (see above).
  • Preflight on rebased head (master db52a965): typecheck ✅ · tests/plugin-agent.test.ts 48/48 ✅ · full suite 2385/2390 — the 3 failures are claude-native e2e tests that fail identically on clean master in this environment (spawn/ps-walk sandbox issues, verified by stash-and-rerun) ✅ · tsup build ✅

…ity registration before dispatch (#1230)

Mirror #1228 on the before_provider_request path: make the handler async
and await registerTools before stamping/reporting. omp's runner awaits
async handlers and sends the resolved payload (verified in the omp
18.0.3 dist), so the plugin-mode claim (the identity:true register that
runs INSIDE registerTools, after the manifest fetch) now serializes
ahead of the single -p dispatch instead of racing it. A losing race
bound the session as an anonymous pfa-*/proxy-mode session with no
round 2 to self-heal.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-24_omp-oneshot-register-await (2a42921)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1237

Each push to this PR publishes a new version under the pr-1237 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1237.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewing this PR now — pulling the branch (2026-09-24_omp-oneshot-register-await @ 2a42921), verifying against issue #1230, and walking the code per the review discipline (issue direction → regression inventory → code → test validity → diff cleanliness). Full conclusion in a follow-up comment. Note: mergeable_state currently reads behind — checking whether the base moved and whether a rebase is needed.

@ranxianglei
ranxianglei merged commit 5871967 into master Sep 24, 2026
8 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-24_omp-oneshot-register-await branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omp one-shot (-p) first request claims proxy mode — identity registration races the single dispatch (same class as #1214)

1 participant